package com.design.design.pattern.structural.proxy.selfPractice.cglibdynamic;

import org.springframework.cglib.proxy.Enhancer;

/**
 * 创建的动态代理对象
 *   1. Enhancer 使用来生成代理对象的类
 *   2. 告诉Enhancer根据那个目标类来生成代理对象
 *   3. 告诉Enhancer要在增强的内容
 *   4. 创建动态代理类,转化为目标接口类型
 * @author TomDragon
 */
public class CglibDynamicClient {
    public static void main(String[] args) {
        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(RealSubject.class);
        enhancer.setCallback(new MethodInterceptorDemo());
        Subject o = (Subject) enhancer.create();
        o.request01();
        o.request02();
        o.request03();
    }
}
